package org.springframework.samples.countries.web.translate;

import java.util.List;
import java.util.Stack;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import pikes.ecma.IExpression;
import pikes.ecma.ReturnStatement;

public class ReturnOperation implements ByteCodeOperation {

	protected static final Log translatorLogger = LogFactory.getLog("Translator");

	private boolean translateEmptyBodyAsReturn = false;

	public void execute(int numberOfParameters, Stack<Object> stack, List<String> localVariables) {
		translatorLogger.info("RETURN");
		if (translateEmptyBodyAsReturn) {
			IExpression expression = (IExpression) stack.pop();
			stack.push(new ReturnStatement(expression));
		}
	}

	@Override
	public String toString() {
		return "return";
	}
}
